<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 300px;
            background-color: #bfa;
        }

        img {
            width: 300px;
        }

        .one {
            text-align: center;
        }
    </style>

</head>

<body>
    <div class="box">
        <img src="../练习题/1.早上好/morning.png" alt="">
        <div class="one">早上好！</div>
    </div>

    <!-- script要写在下面 -->
    <script>
        var time = new Date()
        var h = time.getHours()
        var img = document.querySelector('img')
        var div = document.querySelector('.one')
        if (h < 11) {
            img.src = '../练习题/1.早上好/noon.png'
            div.innerHTML = '早上好！'
        } else if (h > 11 && h < 13) {
            img.src = '../练习题/1.早上好/noon.png'
            div.innerHTML = '中午好！'
        } else {
            img.src = '../练习题/1.早上好/night.png'
            div.innerHTML = '下午好！'
        }
    </script>
</body>

</html>